package org.lwd.datalink.domain.media.parameter.kudu;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.lwd.datalink.domain.media.parameter.MediaSrcParameter;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: weidong.lin
 */
@Getter
@Setter
public class KuduMediaSrcParameter extends MediaSrcParameter {

    private String database;
    private int bufferSize;
    private List<KuduMasterConfig> kuduMasterConfigs;
    private List<ImpalaCconfig> impalaCconfigs;


    public List<String> getHost2Ports() {
        ArrayList<String> host2Ports = new ArrayList<>();
        if (kuduMasterConfigs != null) {
            for (KuduMasterConfig k : kuduMasterConfigs) {
                host2Ports.add(String.format("%s:%d", k.getHost(), k.getPort()));
            }
        }
        return host2Ports;
    }


    public static class KuduMasterConfig {
        private String host;
        private int port;

        public KuduMasterConfig() {
        }

        public KuduMasterConfig(String host, int port) {
            this.host = host;
            this.port = port;
        }

        public String getHost() {
            return host;
        }

        public KuduMasterConfig setHost(String host) {
            this.host = host;
            return this;
        }

        public int getPort() {
            return port;
        }

        public KuduMasterConfig setPort(int port) {
            this.port = port;
            return this;
        }
    }

    @Setter
    @Getter
    @ToString
    public static class ImpalaCconfig {
        private String host;
        private String port;

        public ImpalaCconfig() {
        }

        public ImpalaCconfig(String host, String port) {
            this.host = host;
            this.port = port;
        }
    }
}
